home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / src / Fl_Window.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-13  |  2.9 KB  |  107 lines

  1. //
  2. // "$Id: Fl_Window.cxx,v 1.6 1999/01/13 15:45:49 mike Exp $"
  3. //
  4. // Window widget class for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. // The Fl_Window is a window in the fltk library.
  27. // This is the system-independent portions.  The huge amount of 
  28. // crap you need to do to communicate with X is in Fl_x.C, the
  29. // equivalent (but totally different) crap for MSWindows is in Fl_win32.C
  30.  
  31. #include <FL/Fl.H>
  32. #include <FL/Fl_Window.H>
  33.  
  34. void Fl_Window::_Fl_Window() {
  35.   type(FL_WINDOW);
  36.   box(FL_FLAT_BOX);
  37.   labeltype(FL_NO_LABEL);
  38.   i = 0;
  39.   xclass_ = 0;
  40.   icon_ = 0;
  41.   iconlabel_ = 0;
  42.   resizable(0);
  43.   size_range_set = 0;
  44.   callback((Fl_Callback*)default_callback);
  45. }
  46.  
  47. Fl_Window::Fl_Window(int X,int Y,int W, int H, const char *l)
  48. : Fl_Group(X, Y, W, H, l) {
  49.   _Fl_Window();
  50.   set_flag(FL_FORCE_POSITION);
  51. }
  52.  
  53. Fl_Window::Fl_Window(int W, int H, const char *l)
  54. // fix common user error of a missing end() with current(0):
  55.   : Fl_Group((Fl_Group::current(0),0), 0, W, H, l) {
  56.   _Fl_Window();
  57.   clear_visible();
  58. }
  59.  
  60. Fl_Window *Fl_Widget::window() const {
  61.   for (Fl_Widget *o = parent(); o; o = o->parent())
  62.     if (o->type() >= FL_WINDOW) return (Fl_Window*)o;
  63.   return 0;
  64. }
  65.  
  66. int Fl_Window::x_root() const {
  67.   Fl_Window *p = window();
  68.   if (p) return p->x_root() + x();
  69.   return x();
  70. }
  71.  
  72. int Fl_Window::y_root() const {
  73.   Fl_Window *p = window();
  74.   if (p) return p->y_root() + y();
  75.   return y();
  76. }
  77.  
  78. void Fl_Window::draw() {
  79.   int savex = x(); x(0);
  80.   int savey = y(); y(0);
  81.   Fl_Group::draw();
  82.   y(savey);
  83.   x(savex);
  84. }
  85.  
  86. void Fl_Window::label(const char *name) {label(name, iconlabel());}
  87.  
  88. void Fl_Window::iconlabel(const char *iname) {label(label(), iname);}
  89.  
  90. // the Fl::atclose pointer is provided for back compatability.  You
  91. // can now just change the callback for the window instead.
  92.  
  93. void Fl::default_atclose(Fl_Window* window, void* v) {
  94.   window->hide();
  95.   Fl_Widget::default_callback(window, v); // put on Fl::read_queue()
  96. }
  97.  
  98. void (*Fl::atclose)(Fl_Window*, void*) = default_atclose;
  99.  
  100. void Fl_Window::default_callback(Fl_Window* window, void* v) {
  101.   Fl::atclose(window, v);
  102. }
  103.  
  104. //
  105. // End of "$Id: Fl_Window.cxx,v 1.6 1999/01/13 15:45:49 mike Exp $".
  106. //
  107.